<template>
	<view class="flex_box">
		<u-navbar :border-bottom="false" title="我的地址" back-icon-color="#ffffff" :background="{background:'#2149c3'}" title-color="#ffffff"></u-navbar>
		<view class="soll_box">
			<view class="item" v-for="(res, index) in siteList" :key="res.id" @click="tapList(res)">
				<view class="top">
					<view class="name">{{ res.realname }}</view>
					<view class="phone">{{ res.telephone }}</view>
					<!-- <view class="tag">
						<text v-for="(item, index) in res.tag" :key="index" :class="{red:item.tagText=='默认'}">{{ item.tagText }}</text>
					</view> -->
				</view>
				<view class="bottom">
					<text>{{ res.address }}</text>
					<u-icon name="edit-pen" :size="40" color="#999999" class="zdy_icon"></u-icon>
				</view>
			</view>
		</view>
		<view class="addSite" @tap="toAddSite">
			<view class="add">
				<u-icon name="plus" color="#ffffff" class="icon" :size="30"></u-icon>新建收货地址
			</view>
		</view>
	</view>
</template>

<script>
var _self;
import {
		mapState,
		mapMutations
} from 'vuex';
export default {
	data() {
		return {
			userInfoId:'',
			siteList: [],
			page: {pagenum: 1,pagesize: 10}
		};
	},
	onShow(){
		this.selectAddress();
	},
	onLoad() {
		// this.selectAddress();
	},
	computed: {
		...mapState(['userInfo', 'hasLogin', 'scene', 'openid'])
	},
	methods: {
		getData() {
			this.siteList = [
				{
					id: 1,
					realname: '游X',
					telephone: '183****5523',
					
					address: '广东省深圳市宝安区 自由路66号'
				}
			];
		},
		toAddSite(){
			uni.navigateTo({
			    url: '/newpage/address/addSite'
			});
		},
		tapList:function(r){
			uni.navigateTo({
			    url: '/newpage/address/editSite?obj='+JSON.stringify(r)
			});
		},
		selectAddress: function() {
			uni.request({
				url: this.serverUrl + 'app/getAddressList',
				header: {
					"content-type": "application/x-www-form-urlencoded; charset=UTF-8"
				},
				method: 'POST',
				data: {
					memberId :this.userInfo.id,
					pageSize: this.page.pagesize,
					pageNum: this.page.pagenum
				},
				success: (r) => {
					console.log(r,'getAddressList');
					if (r.data.code == 0) {
						this.siteList = r.data.data
						// this.newsList = r.data.data
					}
				}
			})
		}
	}
};
</script>

<style lang="scss" scoped>
.item {
	padding: 40rpx 30rpx;
	.top {
		display: flex;
		font-weight: bold;
		font-size: 34rpx;
		.phone {
			margin-left: 60rpx;
		}
		.tag {
			display: flex;
			font-weight: normal;
			align-items: center;
			text {
				display: block;
				width: 60rpx;
				height: 34rpx;
				line-height: 34rpx;
				color: #ffffff;
				font-size: 20rpx;
				border-radius: 6rpx;
				text-align: center;
				margin-left: 30rpx;
				background-color:rgb(49, 145, 253);
			}
			.red{
				background-color:red
			}
		}
	}
	.bottom {
		display: flex;
		margin-top: 20rpx;
		font-size: 28rpx;
		justify-content: space-between;
		color: #999999;
	}
	.zdy_icon{
		margin-left: 40rpx;
		margin-right: 20rpx;
	}
}
.flex_box{
	display: flex;
	padding-top:190rpx;
	padding-bottom: 160rpx;
	height: 100vh;
	overflow: hidden;
	.soll_box{
		flex: 1;
		overflow-y: auto;
	}
}

.addSite {
	display: flex;
	justify-content: space-around;
	width: 600rpx;
	line-height: 100rpx;
	position: fixed;
	bottom: 30rpx;
	left: 80rpx;
	background-color: #2149c3;
	border-radius: 60rpx;
	font-size: 30rpx;
	.add{
		display: flex;
		align-items: center;
		color: #ffffff;
		.icon{
			margin-right: 10rpx;
		}
	}
}
</style>
